<?php

namespace Modules\DataAnalysis\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Modules\DataAnalysis\Entities\Video;

class CommentRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
                return [
                    'video_id' => ['required', Rule::exists((new Video)->getTable(), 'id')],
                    'feeling' => ['nullable', Rule::in(['positive', 'passive'])]
                ];
            case 'PUT':
                return [
                    'score' => ['required']
                ];
        }
        return [
            //
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }
}
